/*
package com.maven.front.config;

import com.maven.front.bean.RequestLog;
import com.maven.front.bean.SysLoginLog;
import com.maven.front.bean.SysUser;
import com.maven.front.mapper.SysLoginLogMapper;
import com.maven.front.mapper.SysUserMapper;
import eu.bitwalker.useragentutils.Browser;
import eu.bitwalker.useragentutils.OperatingSystem;
import eu.bitwalker.useragentutils.UserAgent;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;

@Aspect
@Component
public class LogAspect {

              @Resource
              private SysUserMapper sysUserMapper;

              @Resource
              private SysLoginLogMapper sysLoginLogMapper;

              @Resource
              private RedisTemplate redisTemplate;

              private final Logger logger = (Logger) LoggerFactory.getLogger(this.getClass());

              RequestLog requestLog = null;


    */
/**
     * 定义一个切面(第1*:所有请求；第2*:com.basic.hellorabbit.controller下所有类；第3*:所有方法；..任何参数)
     *//*

               @Pointcut("execution(* com.maven.front.controller.*.*.*(..))")
               public void logs(){

               }
    */
/**
     * 切面之前
     * @param joinPoint
     *//*

                @Before("logs()")
               public void Befores(JoinPoint joinPoint){
                    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
                    HttpServletRequest request = attributes.getRequest();
                    String token2=request.getHeader("token2");
                    String url = request.getRequestURL().toString();
                    String ip = request.getRemoteAddr();
                    String classMethod = joinPoint.getSignature().getDeclaringTypeName()+"."+joinPoint.getSignature().getName();
                    Object[] args = joinPoint.getArgs();
                    ArrayList<Object> objects = new ArrayList<>();
                    for (int i = 0; i < args.length; i++) {
                        objects.add(args[i]);
                    }
                    UserAgent userAgent= UserAgent.parseUserAgentString(request.getHeader("User-Agent"));   //req就是request请求
                    Browser browser = userAgent.getBrowser();  //获取浏览器信息
                    OperatingSystem os = userAgent.getOperatingSystem(); //获取操作系统信息
                    StringBuffer userInfo = new StringBuffer();
                    userInfo.append("操作系统："+os.toString()+" 浏览器："+browser.toString());
                    requestLog = new RequestLog(url,ip,classMethod,objects,new Date());//url获取的是访问地址，ip是ip,classMethod是
                    //controller的路径，objecs是传递的参数，new date当前的时间，requestLog是返回值
                    SysLoginLog sysLoginLog=new SysLoginLog();
                    sysLoginLog.setIp(ip);
                    sysLoginLog.setOsName(os.toString());
                    sysLoginLog.setLoginTime(new Date());
                    sysLoginLog.setUserAgent(browser.toString());
                    if(token2!=null){
                        SysUser sysUser=(SysUser)redisTemplate.opsForValue().get(token2);
                        sysUser.setLastLoginIp(ip);
                        sysUser.setLastLoginTime(new Date());
                        sysLoginLog.setUserId(sysUser.getUserId());
                        sysUserMapper.updateByPrimaryKeySelective(sysUser);
                    }
                    sysLoginLogMapper.insertSelective(sysLoginLog);
               }
    */
/**
     * 请求之后
     *//*

    @After("logs()")
    public void doAfter(){
    }

    */
/**
     * 方法执行完返回结果
     * @param result
     *//*

    @AfterReturning(returning = "result",pointcut = "logs()")
    public void doAfterReturn(Object result){
        logger.info("return:"+result);
        requestLog.setResult(result);

        */
/*此处可加入写入数据库操作*//*


    }

}
*/
